import { 
    userTopdirUpadata ,  //更新顶层目录数据
    getUserTopdir  //获取顶层目录数据
} from "./interface/filesystem.js";


export class NoteBook{
    constructor(){
        this.dirData = {
            dir :{},
            len : 0
        };
    }

    install( vm ){
        if( !vm.prototype['$noteBook'] ){
            vm.prototype['$noteBook'] = new NoteBook();
        }
    }

    setTopDirData( name , val ){

        if( !this.dirData.dir[name] ){
            //增加一个未存在的目录
            this.dirData.dir[name] = val;
        }

    }

    getTopDirData( tdata ){
        
        return new Promise( function( resolve , reject ){
            getUserTopdir( tdata ).then( res=>{
                resolve( res );
            }).catch( err=>{
                reject( err );
            } );
        });
        
    }
}

